home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 12980 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.5 KB

  1. Path: news.iosphere.net!usenet
  2. From: ianq@sonetis.com (Ian V. Quickmire)
  3. Newsgroups: comp.lang.c++
  4. Subject: Unable to use 'delete' after 'new'
  5. Date: Fri, 22 Mar 1996 18:34:54 GMT
  6. Organization: IQ Systems Ltd.
  7. Distribution: inet
  8. Message-ID: <4iursi$ibc@lisa.iosphere.net>
  9. Reply-To: ianq@sonetis.com
  10. NNTP-Posting-Host: port016-35-yow.iosphere.net
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. I have 2 definitions of new arrays that I allocate that I am unfortunately
  14. having a hard time deleting afterwards.
  15.  
  16. 1 -     int *iColsize = new int[cCols]; 
  17.  
  18. The trick here is that I need to return this array to the calling function,
  19. which then processes the data. 
  20.  
  21. How do I do the delete from the calling function as opposed to within the
  22. function the NEW was executed.
  23.  
  24. I tried the basic delete [] iColsize from the calling function, and got a
  25. memory exception.
  26.  
  27.  
  28. 2 -     char (*sPassStr)[MAX_COLSIZE + 1] = new
  29. char[iColsize[0]][MAX_COLSIZE + 1]; 
  30.  
  31. The problem here lies with an ODBC function I execute.
  32.  
  33. char (*sPassStr)[MAX_COLSIZE + 1] = new char[iColsize[0]][MAX_COLSIZE + 1];
  34. SQLBindCol(hstmt, i, SQL_C_CHAR, sPassStr[i], iColsize[i], &cbTemp);
  35. retcode = SQLFetch(hstmt);
  36.  
  37. Up until I do the SQLFetch, I can do a 'delete [] sPassStr' fine.
  38. After the Fetch is executed, if I do a delete, I get a memory exception.
  39.  
  40. Any ideas?
  41.  
  42. --------------------------------------------------------------
  43. Work: izq00@ccc.amdahl.com              Home: ianq@sonetis.com
  44. WWW: http://www.sonetis.com/~ianq/      CIS: 74032,573
  45. --------------------------------------------------------------
  46.  
  47.